package com.lanou3g.test.file;

import java.io.File;
import java.io.IOException;

/**
 * Created by dllo on 18/4/14.
 */
public class Main {
    public static void main(String[] args) {
        //  File file = new File("bbb.txt");
        // File file = new File("src/bbb.txt");
        //如果没有路径在创建文件的时候就会失败
        String path = "/Users/dllo/Desktop/Classcode/untitled/res/txt";
        File file = new File(path + File.separator + "bbb.txt");
        boolean exists = file.exists();//判断文件是否存在,存在为true ,不存在为false.
        System.out.println(exists);
        if (exists) {
            file.delete();
        } else {
            try {
                file.createNewFile();
            } catch (Exception e) {
                e.printStackTrace();
            }

        }
    }
}